import java.io.*;
import java.util.StringTokenizer;

class Read {
    StringTokenizer st=new StringTokenizer("");
    BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
    public String next() throws IOException {
        while (!st.hasMoreTokens()){
            st=new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        return bf.readLine();
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}
public class Main {
    public static Read in=new Read();
    public static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main1(String[] args) throws IOException {
        int n= in.nextInt();
        int[] nums=new int[n+1];
        for (int i = 0; i < n; i++) {
            nums[i]= in.nextInt();
        }
        int count=0,i=0;
        while (i<n){
            if(nums[i+1]>nums[i]){
                while (i<n&&nums[i+1]>=nums[i]){
                    i++;
                }
                count++;
                i++;
            } else if (nums[i+1]==nums[i]) {
                i++;
            }
            else {
                while (i<n&&nums[i+1]<=nums[i]){
                    i++;
                }
                count++;
                i++;
            }
        }
        System.out.println(count);
    }

    public static void main2(String[] args) throws IOException {
        int t= in.nextInt();
        while (t-->0){
            int num= in.nextInt();
            int ret=0;
            int i=1;
            while (i<num){
                num-=i;
                ret++;
                if(num%(i*2)==0){
                    i*=2;
                }
            }
            System.out.println(ret);
        }
    }
    public int LIS (int[] a) {
        int[] dp=new int[a.length];
        dp[0]=1;
        int max=0;
        for (int i = 1; i < a.length; i++) {
            dp[i]=1;
            for (int j = 0; j < i; j++) {
                if(a[i]>a[j]){
                    dp[i]=Math.max(dp[j]+1,dp[i]);
                }
            }
            max=Math.max(dp[i],max);
        }
        return max;
    }
}